﻿using System;
namespace Producers.Liiklusregister.Xtee.Riik.Ee.Producer.Liiklusregister.Messages {
    
    
    [global::Xtee.Core.Attributes.XmlTypeAttribute(Name="jlparing1Request", Namespace="http://producers.liiklusregister.xtee.riik.ee/producer/liiklusregister", Target=typeof(Jlparing1Request))]
    public class Jlparing1RequestSerializer : global::Xtee.Core.Types.AbstractXteeSerializable {
        
        protected IJlparing1Request clazz;
        
        public Jlparing1RequestSerializer(IJlparing1Request clazz) {
            this.clazz = clazz;
        }
        
        public override void WriteXml(global::Xtee.Core.IXteeXmlWriter Writer) {
            base.WriteXml(Writer);
            Writer.WriteStartElement("keha");
            if (clazz.Keha!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Keha))).ToString());
            }
            else {
                Writer.WriteAttributeString("xsi", "nil", null, "1");
            }
            Writer.WriteEndElement();
        }
        
        public override void ReadXml(global::Xtee.Core.IXteeXmlReader Reader) {
            base.ReadXml(Reader);
            if (Reader.LocalName=="keha") {
                if ((Reader.IsElementNil() == false)) {
                    clazz.Keha = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("keha")).Value;
                }
                else {
                    Reader.Skip();
                }
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">keha", Reader.LocalName);
            }
        }
    }
}
